package com.wenli.lt.controller;


import com.wenli.lt.entity.Collections;
import com.wenli.lt.entity.Fans;
import com.wenli.lt.service.IFansService;
import com.wenli.lt.util.CommonResponse;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lt
 * @since 2021-03-24
 */
@RestController
@Api(tags="粉丝关注")
@RequestMapping("fans")
public class FansController {

    @Autowired
    IFansService fansService;

    @GetMapping("getFansInfoByNo")
    @ApiOperation("通过学号查询粉丝列表  关注列表  0  粉丝列表  1 关注列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "studentNumber",value = "学号"),
            @ApiImplicitParam(name = "status",value = "状态  0  查询粉丝列表  1 查询关注列表"),
    })
    public CommonResponse getFansInfoByNo(String studentNumber,Integer status){

        return new CommonResponse(fansService.getFansInfoByNo(studentNumber,status));
    }

    @PostMapping("/addBeFans")
    @ApiOperation("新增关注")
    public CommonResponse addBeFans(@RequestBody @ApiParam(name = "fans", value = "粉丝") Fans fans){
        if (fansService.addBeFans(fans)){
            return new CommonResponse("关注成功");
        }else {
            return new CommonResponse(CommonResponse.ERROR_CODE,"关注出错,请联系管理员!");
        }
    }

    @PostMapping("cancelBeFans")
    @ApiOperation("取消关注")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "focusId",value = "关注人学号"),
            @ApiImplicitParam(name = "befocusId",value = "被关注人学号")
    })
    public CommonResponse cancelBeFans(String focusId,String befocusId){
        if (fansService.cancelBeFans(focusId,befocusId)){
            return new CommonResponse("关注取消");
        }else {
            return new CommonResponse(CommonResponse.ERROR_CODE,"取消关注出错,请联系管理员!");
        }
    }




}
